import { Navigate } from "react-router-dom";
import Login from "../view/Login";
import Layout from "../view/layout";
import User from "../view/Home/User";
import Admin from "../view/Home/Admin";
import NotFound from "../view/NotFound";

// 只对component属性配置的组件处理为懒加载，不想用懒加载的就用element属性配置组件。
const routes = [
  {
    path: "/",
    element: <Navigate to="/login" />,
  },
  {
    path: "/login",
    element: <Login />,
  },
  {
    path: "home/*",
    element: <Layout />,
    children: [
      {
        path: "",
        element: <Navigate to="user" />,
      },
      {
        path: "user",
        element: <User />,
      },
      {
        path: "admin",
        element: <Admin />,
      },
      {
        path: "*",
        element: <NotFound />,
      },
    ],
  },
  {
    path: "*",
    element: <NotFound />,
  },
];

export { routes };
